3.1.33 \(\int \frac {\tan (c+d x) (B \tan (c+d x)+C \tan ^2(c+d x))}{(a+b \tan (c+d x))^2} \, dx\) [33]

3.1.33.1 Optimal result
3.1.33.2 Mathematica [C] (verified)
3.1.33.3 Rubi [A] (verified)
3.1.33.4 Maple [A] (verified)
3.1.33.5 Fricas [B] (verification not implemented)
3.1.33.6 Sympy [C] (verification not implemented)
3.1.33.7 Maxima [A] (verification not implemented)
3.1.33.8 Giac [A] (verification not implemented)
3.1.33.9 Mupad [B] (verification not implemented)

3.1.33.1 Optimal result

Integrand size = 38, antiderivative size = 157 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=-\frac {\left (a^2 B-b^2 B+2 a b C\right ) x}{\left (a^2+b^2\right )^2}-\frac {\left (2 a b B-a^2 C+b^2 C\right ) \log (\cos (c+d x))}{\left (a^2+b^2\right )^2 d}-\frac {a \left (2 b^3 B-a^3 C-3 a b^2 C\right ) \log (a+b \tan (c+d x))}{b^2 \left (a^2+b^2\right )^2 d}-\frac {a^2 (b B-a C)}{b^2 \left (a^2+b^2\right ) d (a+b \tan (c+d x))} \]

output
-(B*a^2-B*b^2+2*C*a*b)*x/(a^2+b^2)^2-(2*B*a*b-C*a^2+C*b^2)*ln(cos(d*x+c))/ 
(a^2+b^2)^2/d-a*(2*B*b^3-C*a^3-3*C*a*b^2)*ln(a+b*tan(d*x+c))/b^2/(a^2+b^2) 
^2/d-a^2*(B*b-C*a)/b^2/(a^2+b^2)/d/(a+b*tan(d*x+c))
 
3.1.33.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 2.90 (sec) , antiderivative size = 146, normalized size of antiderivative = 0.93 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=\frac {\frac {i (B+i C) \log (i-\tan (c+d x))}{(a+i b)^2}-\frac {i (B-i C) \log (i+\tan (c+d x))}{(a-i b)^2}+\frac {2 a \left (\left (-2 b B+3 a C+\frac {a^3 C}{b^2}\right ) \log (a+b \tan (c+d x))+\frac {a \left (a^2+b^2\right ) (-b B+a C)}{b^2 (a+b \tan (c+d x))}\right )}{\left (a^2+b^2\right )^2}}{2 d} \]

input
Integrate[(Tan[c + d*x]*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c 
+ d*x])^2,x]
 
output
((I*(B + I*C)*Log[I - Tan[c + d*x]])/(a + I*b)^2 - (I*(B - I*C)*Log[I + Ta 
n[c + d*x]])/(a - I*b)^2 + (2*a*((-2*b*B + 3*a*C + (a^3*C)/b^2)*Log[a + b* 
Tan[c + d*x]] + (a*(a^2 + b^2)*(-(b*B) + a*C))/(b^2*(a + b*Tan[c + d*x]))) 
)/(a^2 + b^2)^2)/(2*d)
 
3.1.33.3 Rubi [A] (verified)

Time = 0.88 (sec) , antiderivative size = 171, normalized size of antiderivative = 1.09, number of steps used = 12, number of rules used = 11, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.289, Rules used = {3042, 4115, 3042, 4087, 25, 3042, 4109, 3042, 3956, 4100, 16}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan (c+d x)^2\right )}{(a+b \tan (c+d x))^2}dx\)

\(\Big \downarrow \) 4115

\(\displaystyle \int \frac {\tan ^2(c+d x) (B+C \tan (c+d x))}{(a+b \tan (c+d x))^2}dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {\tan (c+d x)^2 (B+C \tan (c+d x))}{(a+b \tan (c+d x))^2}dx\)

\(\Big \downarrow \) 4087

\(\displaystyle \frac {\int -\frac {-\left (\left (a^2+b^2\right ) C \tan ^2(c+d x)\right )-b (b B-a C) \tan (c+d x)+a (b B-a C)}{a+b \tan (c+d x)}dx}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 25

\(\displaystyle -\frac {\int \frac {-\left (\left (a^2+b^2\right ) C \tan ^2(c+d x)\right )-b (b B-a C) \tan (c+d x)+a (b B-a C)}{a+b \tan (c+d x)}dx}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {\int \frac {-\left (\left (a^2+b^2\right ) C \tan (c+d x)^2\right )-b (b B-a C) \tan (c+d x)+a (b B-a C)}{a+b \tan (c+d x)}dx}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 4109

\(\displaystyle -\frac {-\frac {b \left (a^2 (-C)+2 a b B+b^2 C\right ) \int \tan (c+d x)dx}{a^2+b^2}+\frac {a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \int \frac {\tan ^2(c+d x)+1}{a+b \tan (c+d x)}dx}{a^2+b^2}+\frac {b x \left (a^2 B+2 a b C-b^2 B\right )}{a^2+b^2}}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle -\frac {-\frac {b \left (a^2 (-C)+2 a b B+b^2 C\right ) \int \tan (c+d x)dx}{a^2+b^2}+\frac {a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \int \frac {\tan (c+d x)^2+1}{a+b \tan (c+d x)}dx}{a^2+b^2}+\frac {b x \left (a^2 B+2 a b C-b^2 B\right )}{a^2+b^2}}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 3956

\(\displaystyle -\frac {\frac {a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \int \frac {\tan (c+d x)^2+1}{a+b \tan (c+d x)}dx}{a^2+b^2}+\frac {b \left (a^2 (-C)+2 a b B+b^2 C\right ) \log (\cos (c+d x))}{d \left (a^2+b^2\right )}+\frac {b x \left (a^2 B+2 a b C-b^2 B\right )}{a^2+b^2}}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 4100

\(\displaystyle -\frac {\frac {a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \int \frac {1}{a+b \tan (c+d x)}d(b \tan (c+d x))}{b d \left (a^2+b^2\right )}+\frac {b \left (a^2 (-C)+2 a b B+b^2 C\right ) \log (\cos (c+d x))}{d \left (a^2+b^2\right )}+\frac {b x \left (a^2 B+2 a b C-b^2 B\right )}{a^2+b^2}}{b \left (a^2+b^2\right )}-\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}\)

\(\Big \downarrow \) 16

\(\displaystyle -\frac {a^2 (b B-a C)}{b^2 d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac {\frac {b \left (a^2 (-C)+2 a b B+b^2 C\right ) \log (\cos (c+d x))}{d \left (a^2+b^2\right )}+\frac {b x \left (a^2 B+2 a b C-b^2 B\right )}{a^2+b^2}+\frac {a \left (a^3 (-C)-3 a b^2 C+2 b^3 B\right ) \log (a+b \tan (c+d x))}{b d \left (a^2+b^2\right )}}{b \left (a^2+b^2\right )}\)

input
Int[(Tan[c + d*x]*(B*Tan[c + d*x] + C*Tan[c + d*x]^2))/(a + b*Tan[c + d*x] 
)^2,x]
 
output
-(((b*(a^2*B - b^2*B + 2*a*b*C)*x)/(a^2 + b^2) + (b*(2*a*b*B - a^2*C + b^2 
*C)*Log[Cos[c + d*x]])/((a^2 + b^2)*d) + (a*(2*b^3*B - a^3*C - 3*a*b^2*C)* 
Log[a + b*Tan[c + d*x]])/(b*(a^2 + b^2)*d))/(b*(a^2 + b^2))) - (a^2*(b*B - 
 a*C))/(b^2*(a^2 + b^2)*d*(a + b*Tan[c + d*x]))
 

3.1.33.3.1 Defintions of rubi rules used

rule 16
Int[(c_.)/((a_.) + (b_.)*(x_)), x_Symbol] :> Simp[c*(Log[RemoveContent[a + 
b*x, x]]/b), x] /; FreeQ[{a, b, c}, x]
 

rule 25
Int[-(Fx_), x_Symbol] :> Simp[Identity[-1]   Int[Fx, x], x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3956
Int[tan[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Log[RemoveContent[Cos[c + d 
*x], x]]/d, x] /; FreeQ[{c, d}, x]
 

rule 4087
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^2*((A_.) + (B_.)*tan[(e_.) + (f 
_.)*(x_)])*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Simp[ 
(-(B*c - A*d))*(b*c - a*d)^2*((c + d*Tan[e + f*x])^(n + 1)/(f*d^2*(n + 1)*( 
c^2 + d^2))), x] + Simp[1/(d*(c^2 + d^2))   Int[(c + d*Tan[e + f*x])^(n + 1 
)*Simp[B*(b*c - a*d)^2 + A*d*(a^2*c - b^2*c + 2*a*b*d) + d*(B*(a^2*c - b^2* 
c + 2*a*b*d) + A*(2*a*b*c - a^2*d + b^2*d))*Tan[e + f*x] + b^2*B*(c^2 + d^2 
)*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B}, x] && NeQ[b 
*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] && LtQ[n, -1]
 

rule 4100
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_) + (C_.)*tan[(e_.) + 
 (f_.)*(x_)]^2), x_Symbol] :> Simp[A/(b*f)   Subst[Int[(a + x)^m, x], x, b* 
Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, A, C, m}, x] && EqQ[A, C]
 

rule 4109
Int[((A_) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2 
)/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(a*A + b*B - a 
*C)*(x/(a^2 + b^2)), x] + (Simp[(A*b^2 - a*b*B + a^2*C)/(a^2 + b^2)   Int[( 
1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x]), x], x] - Simp[(A*b - a*B - b*C)/( 
a^2 + b^2)   Int[Tan[e + f*x], x], x]) /; FreeQ[{a, b, e, f, A, B, C}, x] & 
& NeQ[A*b^2 - a*b*B + a^2*C, 0] && NeQ[a^2 + b^2, 0] && NeQ[A*b - a*B - b*C 
, 0]
 

rule 4115
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) 
+ (f_.)*(x_)])^(n_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_ 
.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[1/b^2   Int[(a + b*Tan[e + f*x])^(m 
+ 1)*(c + d*Tan[e + f*x])^n*(b*B - a*C + b*C*Tan[e + f*x]), x], x] /; FreeQ 
[{a, b, c, d, e, f, A, B, C, m, n}, x] && NeQ[b*c - a*d, 0] && EqQ[A*b^2 - 
a*b*B + a^2*C, 0]
 
3.1.33.4 Maple [A] (verified)

Time = 0.13 (sec) , antiderivative size = 155, normalized size of antiderivative = 0.99

method result size
derivativedivides \(\frac {\frac {\frac {\left (2 B a b -C \,a^{2}+C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-B \,a^{2}+B \,b^{2}-2 C a b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2} \left (B b -C a \right )}{b^{2} \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}-\frac {a \left (2 B \,b^{3}-C \,a^{3}-3 C a \,b^{2}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2} b^{2}}}{d}\) \(155\)
default \(\frac {\frac {\frac {\left (2 B a b -C \,a^{2}+C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2}+\left (-B \,a^{2}+B \,b^{2}-2 C a b \right ) \arctan \left (\tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2} \left (B b -C a \right )}{b^{2} \left (a^{2}+b^{2}\right ) \left (a +b \tan \left (d x +c \right )\right )}-\frac {a \left (2 B \,b^{3}-C \,a^{3}-3 C a \,b^{2}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{2}+b^{2}\right )^{2} b^{2}}}{d}\) \(155\)
norman \(\frac {-\frac {a \left (B \,a^{2}-B \,b^{2}+2 C a b \right ) x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {b \left (B \,a^{2}-B \,b^{2}+2 C a b \right ) x \tan \left (d x +c \right )}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {\left (B a b -C \,a^{2}\right ) a}{d \,b^{2} \left (a^{2}+b^{2}\right )}}{a +b \tan \left (d x +c \right )}+\frac {\left (2 B a b -C \,a^{2}+C \,b^{2}\right ) \ln \left (1+\tan \left (d x +c \right )^{2}\right )}{2 d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {a \left (2 B \,b^{3}-C \,a^{3}-3 C a \,b^{2}\right ) \ln \left (a +b \tan \left (d x +c \right )\right )}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) d \,b^{2}}\) \(234\)
parallelrisch \(\frac {2 C \,a^{5}-2 B \,a^{4} b +2 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) \tan \left (d x +c \right ) a \,b^{4}-4 B \ln \left (a +b \tan \left (d x +c \right )\right ) \tan \left (d x +c \right ) a \,b^{4}-C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) \tan \left (d x +c \right ) a^{2} b^{3}+2 C \ln \left (a +b \tan \left (d x +c \right )\right ) \tan \left (d x +c \right ) a^{4} b +6 C \ln \left (a +b \tan \left (d x +c \right )\right ) \tan \left (d x +c \right ) a^{2} b^{3}+2 B x \tan \left (d x +c \right ) b^{5} d -2 B x \,a^{3} b^{2} d +2 B x a \,b^{4} d -4 C x \,a^{2} b^{3} d -2 B \,a^{2} b^{3}+2 C \,a^{3} b^{2}+C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) \tan \left (d x +c \right ) b^{5}+2 B \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{2} b^{3}-4 B \ln \left (a +b \tan \left (d x +c \right )\right ) a^{2} b^{3}-C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a^{3} b^{2}+C \ln \left (1+\tan \left (d x +c \right )^{2}\right ) a \,b^{4}+6 C \ln \left (a +b \tan \left (d x +c \right )\right ) a^{3} b^{2}-2 B x \tan \left (d x +c \right ) a^{2} b^{3} d -4 C x \tan \left (d x +c \right ) a \,b^{4} d +2 C \ln \left (a +b \tan \left (d x +c \right )\right ) a^{5}}{2 \left (a +b \tan \left (d x +c \right )\right ) \left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) d \,b^{2}}\) \(407\)
risch \(\frac {x B}{2 i b a -a^{2}+b^{2}}+\frac {4 i a b B x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {6 i a^{2} C x}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {2 i C c}{b^{2} d}+\frac {2 i a^{2} B}{\left (i b +a \right ) d \left (-i b +a \right )^{2} \left (-i b \,{\mathrm e}^{2 i \left (d x +c \right )}+a \,{\mathrm e}^{2 i \left (d x +c \right )}+i b +a \right )}-\frac {2 i a^{3} C}{\left (i b +a \right ) d b \left (-i b +a \right )^{2} \left (-i b \,{\mathrm e}^{2 i \left (d x +c \right )}+a \,{\mathrm e}^{2 i \left (d x +c \right )}+i b +a \right )}-\frac {6 i a^{2} C c}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 i a^{4} C c}{b^{2} d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 i C x}{b^{2}}-\frac {i x C}{2 i b a -a^{2}+b^{2}}-\frac {2 i a^{4} C x}{b^{2} \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {4 i a b B c}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 a b \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) B}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {a^{4} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) C}{b^{2} d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {3 a^{2} \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}-\frac {i b +a}{i b -a}\right ) C}{d \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {C \ln \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}{b^{2} d}\) \(530\)

input
int(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x,method=_ 
RETURNVERBOSE)
 
output
1/d*(1/(a^2+b^2)^2*(1/2*(2*B*a*b-C*a^2+C*b^2)*ln(1+tan(d*x+c)^2)+(-B*a^2+B 
*b^2-2*C*a*b)*arctan(tan(d*x+c)))-a^2*(B*b-C*a)/b^2/(a^2+b^2)/(a+b*tan(d*x 
+c))-a*(2*B*b^3-C*a^3-3*C*a*b^2)/(a^2+b^2)^2/b^2*ln(a+b*tan(d*x+c)))
 
3.1.33.5 Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 311 vs. \(2 (153) = 306\).

Time = 0.29 (sec) , antiderivative size = 311, normalized size of antiderivative = 1.98 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=\frac {2 \, C a^{3} b^{2} - 2 \, B a^{2} b^{3} - 2 \, {\left (B a^{3} b^{2} + 2 \, C a^{2} b^{3} - B a b^{4}\right )} d x + {\left (C a^{5} + 3 \, C a^{3} b^{2} - 2 \, B a^{2} b^{3} + {\left (C a^{4} b + 3 \, C a^{2} b^{3} - 2 \, B a b^{4}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac {b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - {\left (C a^{5} + 2 \, C a^{3} b^{2} + C a b^{4} + {\left (C a^{4} b + 2 \, C a^{2} b^{3} + C b^{5}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac {1}{\tan \left (d x + c\right )^{2} + 1}\right ) - 2 \, {\left (C a^{4} b - B a^{3} b^{2} + {\left (B a^{2} b^{3} + 2 \, C a b^{4} - B b^{5}\right )} d x\right )} \tan \left (d x + c\right )}{2 \, {\left ({\left (a^{4} b^{3} + 2 \, a^{2} b^{5} + b^{7}\right )} d \tan \left (d x + c\right ) + {\left (a^{5} b^{2} + 2 \, a^{3} b^{4} + a b^{6}\right )} d\right )}} \]

input
integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, a 
lgorithm="fricas")
 
output
1/2*(2*C*a^3*b^2 - 2*B*a^2*b^3 - 2*(B*a^3*b^2 + 2*C*a^2*b^3 - B*a*b^4)*d*x 
 + (C*a^5 + 3*C*a^3*b^2 - 2*B*a^2*b^3 + (C*a^4*b + 3*C*a^2*b^3 - 2*B*a*b^4 
)*tan(d*x + c))*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan(d 
*x + c)^2 + 1)) - (C*a^5 + 2*C*a^3*b^2 + C*a*b^4 + (C*a^4*b + 2*C*a^2*b^3 
+ C*b^5)*tan(d*x + c))*log(1/(tan(d*x + c)^2 + 1)) - 2*(C*a^4*b - B*a^3*b^ 
2 + (B*a^2*b^3 + 2*C*a*b^4 - B*b^5)*d*x)*tan(d*x + c))/((a^4*b^3 + 2*a^2*b 
^5 + b^7)*d*tan(d*x + c) + (a^5*b^2 + 2*a^3*b^4 + a*b^6)*d)
 
3.1.33.6 Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 1.08 (sec) , antiderivative size = 3497, normalized size of antiderivative = 22.27 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=\text {Too large to display} \]

input
integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)**2)/(a+b*tan(d*x+c))**2,x)
 
output
Piecewise((zoo*x*(B*tan(c) + C*tan(c)**2)/tan(c), Eq(a, 0) & Eq(b, 0) & Eq 
(d, 0)), ((-B*x + B*tan(c + d*x)/d - C*log(tan(c + d*x)**2 + 1)/(2*d) + C* 
tan(c + d*x)**2/(2*d))/a**2, Eq(b, 0)), (B*d*x*tan(c + d*x)**2/(4*b**2*d*t 
an(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 2*I*B*d*x*tan(c + d 
*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - B*d* 
x/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 3*B*ta 
n(c + d*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) 
 + 2*I*B/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) + 
 3*I*C*d*x*tan(c + d*x)**2/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + 
d*x) - 4*b**2*d) + 6*C*d*x*tan(c + d*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I*b* 
*2*d*tan(c + d*x) - 4*b**2*d) - 3*I*C*d*x/(4*b**2*d*tan(c + d*x)**2 - 8*I* 
b**2*d*tan(c + d*x) - 4*b**2*d) + 2*C*log(tan(c + d*x)**2 + 1)*tan(c + d*x 
)**2/(4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 4*I 
*C*log(tan(c + d*x)**2 + 1)*tan(c + d*x)/(4*b**2*d*tan(c + d*x)**2 - 8*I*b 
**2*d*tan(c + d*x) - 4*b**2*d) - 2*C*log(tan(c + d*x)**2 + 1)/(4*b**2*d*ta 
n(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 5*I*C*tan(c + d*x)/( 
4*b**2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d) - 4*C/(4*b* 
*2*d*tan(c + d*x)**2 - 8*I*b**2*d*tan(c + d*x) - 4*b**2*d), Eq(a, -I*b)), 
(B*d*x*tan(c + d*x)**2/(4*b**2*d*tan(c + d*x)**2 + 8*I*b**2*d*tan(c + d*x) 
 - 4*b**2*d) + 2*I*B*d*x*tan(c + d*x)/(4*b**2*d*tan(c + d*x)**2 + 8*I*b...
 
3.1.33.7 Maxima [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 197, normalized size of antiderivative = 1.25 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=-\frac {\frac {2 \, {\left (B a^{2} + 2 \, C a b - B b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {2 \, {\left (C a^{4} + 3 \, C a^{2} b^{2} - 2 \, B a b^{3}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} b^{2} + 2 \, a^{2} b^{4} + b^{6}} + \frac {{\left (C a^{2} - 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {2 \, {\left (C a^{3} - B a^{2} b\right )}}{a^{3} b^{2} + a b^{4} + {\left (a^{2} b^{3} + b^{5}\right )} \tan \left (d x + c\right )}}{2 \, d} \]

input
integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, a 
lgorithm="maxima")
 
output
-1/2*(2*(B*a^2 + 2*C*a*b - B*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - 2*(C 
*a^4 + 3*C*a^2*b^2 - 2*B*a*b^3)*log(b*tan(d*x + c) + a)/(a^4*b^2 + 2*a^2*b 
^4 + b^6) + (C*a^2 - 2*B*a*b - C*b^2)*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2 
*b^2 + b^4) - 2*(C*a^3 - B*a^2*b)/(a^3*b^2 + a*b^4 + (a^2*b^3 + b^5)*tan(d 
*x + c)))/d
 
3.1.33.8 Giac [A] (verification not implemented)

Time = 0.56 (sec) , antiderivative size = 244, normalized size of antiderivative = 1.55 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=-\frac {\frac {2 \, {\left (B a^{2} + 2 \, C a b - B b^{2}\right )} {\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {{\left (C a^{2} - 2 \, B a b - C b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {2 \, {\left (C a^{4} + 3 \, C a^{2} b^{2} - 2 \, B a b^{3}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b^{2} + 2 \, a^{2} b^{4} + b^{6}} + \frac {2 \, {\left (C a^{4} \tan \left (d x + c\right ) + 3 \, C a^{2} b^{2} \tan \left (d x + c\right ) - 2 \, B a b^{3} \tan \left (d x + c\right ) + B a^{4} + 2 \, C a^{3} b - B a^{2} b^{2}\right )}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} {\left (b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \]

input
integrate(tan(d*x+c)*(B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, a 
lgorithm="giac")
 
output
-1/2*(2*(B*a^2 + 2*C*a*b - B*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) + (C*a 
^2 - 2*B*a*b - C*b^2)*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) - 2* 
(C*a^4 + 3*C*a^2*b^2 - 2*B*a*b^3)*log(abs(b*tan(d*x + c) + a))/(a^4*b^2 + 
2*a^2*b^4 + b^6) + 2*(C*a^4*tan(d*x + c) + 3*C*a^2*b^2*tan(d*x + c) - 2*B* 
a*b^3*tan(d*x + c) + B*a^4 + 2*C*a^3*b - B*a^2*b^2)/((a^4*b + 2*a^2*b^3 + 
b^5)*(b*tan(d*x + c) + a)))/d
 
3.1.33.9 Mupad [B] (verification not implemented)

Time = 8.65 (sec) , antiderivative size = 165, normalized size of antiderivative = 1.05 \[ \int \frac {\tan (c+d x) \left (B \tan (c+d x)+C \tan ^2(c+d x)\right )}{(a+b \tan (c+d x))^2} \, dx=\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )+1{}\mathrm {i}\right )\,\left (C+B\,1{}\mathrm {i}\right )}{2\,d\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}+\frac {\ln \left (\mathrm {tan}\left (c+d\,x\right )-\mathrm {i}\right )\,\left (B+C\,1{}\mathrm {i}\right )}{2\,d\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {a^2\,\left (B\,b-C\,a\right )}{b^2\,d\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )}+\frac {a\,\ln \left (a+b\,\mathrm {tan}\left (c+d\,x\right )\right )\,\left (C\,a^3+3\,C\,a\,b^2-2\,B\,b^3\right )}{b^2\,d\,{\left (a^2+b^2\right )}^2} \]

input
int((tan(c + d*x)*(B*tan(c + d*x) + C*tan(c + d*x)^2))/(a + b*tan(c + d*x) 
)^2,x)
 
output
(log(tan(c + d*x) + 1i)*(B*1i + C))/(2*d*(a*b*2i - a^2 + b^2)) + (log(tan( 
c + d*x) - 1i)*(B + C*1i))/(2*d*(2*a*b - a^2*1i + b^2*1i)) - (a^2*(B*b - C 
*a))/(b^2*d*(a^2 + b^2)*(a + b*tan(c + d*x))) + (a*log(a + b*tan(c + d*x)) 
*(C*a^3 - 2*B*b^3 + 3*C*a*b^2))/(b^2*d*(a^2 + b^2)^2)